// 购物车
$('.gouwu').hover(function(){
        $(this).css('color','orangered').css('background-color','#fff')
        .css('transition-delay','0s');
        $('.mes').stop().slideDown(300);
},function(){
        $(this).css('color','#b0b0b0')
        .css('background-color','rgba(200, 200, 200, 0.1)').css('transition-delay','0.3s');
        $('.mes').stop().slideUp(300);
});

// 导航栏 搜索栏
$('.list li').hover(function(){
    $(this).css('color','orangered');
    if($(this).index() < 7){
        $('.nav-show').stop().slideDown(300);
        $('.nav-show ul').eq($(this).index()).show().siblings().hide();
    } 
    $('.nav-show').mouseenter(function(){
            $('.nav-show').stop().slideDown(300);
        });
    $('.nav-show').mouseleave( function(){
            $('.nav-show').stop().slideUp(300);
        });  
    if($(this).index() > 6){
        $('.nav-show').stop().slideUp(300);
    }
},function(){
    $('.nav-show').stop().slideUp(300);
    $(this).css('color','black');
});



$('.select input').focusin(function(){
    $('.select-a').hide();
    $('.select-show').show();
    $('.select').css('border','1px solid orangered');
    $('.select span').css('background-color','orangered');
});
$('.select input').focusout(function(){
    $('.select-a').show();
    $('.select-show').hide();
    $('.select').css('border','1px solid #dcdcdc');
    $('.select span').css('background-color','#dcdcdc');
});


// 轮播

var index = 0;
    var timer = setInterval(nextImg,3000);
    function prevImg() {
        index = index==0 ? index=6 : index-1;
        showImg();
    }
    function nextImg() {
        index = index==6 ? 0 : index+1;
        showImg();
    }
    function showImg(){
        $('.img-list li').eq(index).stop().fadeIn(200).siblings().stop().fadeOut(200);
        $('.indicator li').eq(index).addClass('active').siblings().removeClass('active');
    }

    $('.box').mouseenter(function(){
        clearInterval(timer);
        $('.img-click span').show();
    }).mouseleave(function(){
        timer = setInterval(nextImg,3000);
        $('.img-click span').hide();
    });
    // 根据指示灯切换
    $('.indicator li').hover(function(){
        index = $(this).index();
        showImg();
    });

    // 点击切换
    $('.prev').click(function(){
         prevImg();
    });
    $('.next').click(function(){
         nextImg();
    });

    $('.box-nav').children('ul').hover(function(){
        $(this).children('.nav-message').show();
    },function(){
        $(this).children('.nav-message').hide();
    });


    // 明星单品轮播

    var mingTime = setInterval(back,5000);
    var mingTF = true;
    function back(){
        if(mingTF == true){
            $('.starProducts-img ul').animate({left:-1245},500);
            $('.starProducts-top div div').eq('0').css('opacity','1').siblings().css('opacity','0.5');
            mingTF = false;
        }else{
            $('.starProducts-img ul').animate({left:0},500);
            $('.starProducts-top div div').eq('1').css('opacity','1').siblings().css('opacity','0.5');
            mingTF = true;
        }
    }
    $('.starProducts-top .mingclick div').hover(function(){
        if(mingTF == true && $(this).index() == 1){
            $(this).css('color','orangered');
            clearInterval(mingTime);
        }else if(mingTF == false && $(this).index() == 0){
            $(this).css('color','orangered');
            clearInterval(mingTime);
        }else{
            $(this).css('color','#888');
        }
    },function(){
        $(this).css('color','#888');
        if(mingTF == true && $(this).index() == 1 || mingTF == false && $(this).index() == 0){
            mingTime = setInterval(back,5000);
        }    
    });
    $('.starProducts-top .mingclick div').eq('1').click(function(){
        $(this).css('color','#888');
        mingTF = true;
        if(mingTime != null){
            clearInterval(mingTime);
        }
        mingTime = setInterval(back,5000);
        back();
    });
    $('.starProducts-top .mingclick div').eq('0').click(function(){
        $(this).css('color','#888');
        mingTF = false;
        if(mingTime != null){
            clearInterval(mingTime);
        }
        mingTime = setInterval(back,5000);
        back();
    });


    // 家电
    $('.products-content-right ul li').each(function(){
        if($(this).index() < 7){
            $(this).hover(function(){
                $(this).css('box-shadow','0 15px 15px rgba(0, 0, 0, 0.2)')
                .css('top','-5px');
                $(this).children('.oranger').stop().animate({bottom:0},200);
            },function(){
                 $(this).css('box-shadow','0 0 0 rgba(0, 0, 0, 0)')
                .css('top','0px');
                $(this).children('.oranger').stop().animate({bottom:-75},200);
            });
        }
    });
    $('.main-padding').children('.products').mouseenter(function(){
        var $mainIndex = $(this).index(); 
        var lastIndex1=0;
        ulShow($(this).index(),lastIndex1);
        
    });
    function ulShow(index,lastIndex1){
        $('.products-head').eq(index).find('li').mouseenter(function(){
            $(this).addClass('list-show').siblings().removeClass('list-show');
            if(lastIndex1 != $(this).index()){
                $('.products-head').eq(index).find('li').children('p').removeClass('p-show').stop().fadeOut(0);
            }
            $(this).children('p').stop().fadeIn(600);
            $('.products-content').eq(index).children('.products-content-right').children('ul').eq($(this).index()).addClass('message-show').siblings().removeClass('message-show');
            lastIndex1 = $(this).index();
        });
    }

    // 推荐
    var recommendTF = true;
    function recommedback(){
        if(recommendTF == true){
            $('.recommend-img ul').stop().animate({left:-1245},300);
            $('.recommend-top div div').eq('0').css('opacity','1').siblings().css('opacity','0.4');
            recommendTF = false;
        }else{
            $('.recommend-img ul').stop().animate({left:0},300);
            $('.recommend-top div div').eq('1').css('opacity','1').siblings().css('opacity','0.4');
            recommendTF = true;
        }
    }
    $('.recommend-top .recommend-click div').hover(function(){
        if(recommendTF == true && $(this).index() == 1){
            $(this).css('color','orangered');
            $(this).click(function(){
                $(this).css('color','#888');
                recommendTF = true;
                recommedback();
            });
        }else if(recommendTF == false && $(this).index() == 0){
            $(this).css('color','orangered');
            $(this).click(function(){
                $(this).css('color','#888');
                recommendTF = false;
                recommedback();
            });
        }else{
            $(this).css('color','#888');
        }
    },function(){
        $(this).css('color','#888');  
    });


    // 内容

    $('.messAges-img').children('div').mouseenter(function(){
        var $mesIndex = $(this).index();
        var mesCount = 0;
        var $mesLength = $(this).children('ul').children('li').length-1;
        $(this).find('.down-img').click(function(){
            mesCount++;
            if(mesCount <= $mesLength){
                $('.mes-chioce').eq($mesIndex).children('ul').stop().animate({left:-(296*mesCount)},500);
                $('.mes-chioce').eq($mesIndex).children('.mes-light1').find('li').eq(mesCount)
                .addClass('light-show').siblings().removeClass('light-show');
            }else{
                 mesCount = $mesLength;
            }
            console.log(mesCount);
           
        });
        $(this).find('.up-img').click(function(){
            mesCount--;
            if(mesCount >=0){
                $('.mes-chioce').eq($mesIndex).children('ul').stop().animate({left:-(296*mesCount)},500);
                $('.mes-chioce').eq($mesIndex).children('.mes-light1').find('li').eq(mesCount)
                .addClass('light-show').siblings().removeClass('light-show');
            }else{
                mesCount = 0;
            }
           console.log(mesCount);
        });
    });
    $('.videos ul').find('img').hover(function(){
        $(this).siblings('div').css('border','3px solid orangered').css('background-color','orangered');
    },function(){
        $(this).siblings('div').hover(function(){
            $(this).css('border','3px solid orangered').css('background-color','orangered');
        });
        $(this).siblings('div').css('border','3px solid #fff').css('background-color','rgba(0, 0, 0, 0.5)');
    });

